package com.yycx.module.bus.provider.handler.client;

import com.yycx.common.base.utils.FlymeUtils;
import com.yycx.module.bus.client.entity.hy.HyOrder;
import com.yycx.module.bus.client.entity.hy.HyOrderDetail;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

/**
 * 海鹰订单详情计算元素
 *
 * @author zyf
 */
@Data
public class HyOrderDetailsVo implements Serializable {


    /**
     * 订单信息
     */
    private HyOrder hyOrder;

    /**
     * 订单明细
     */
    private HyOrderDetail hyOrderDetail;


    /**
     * 折扣价
     */
    private BigDecimal discountPrice;


    /**
     * 初始化公式计算元素
     *
     * @return
     */
    public Map<String, Object> getVariable() {
        Map<String, Object> variable = new HashMap<>(5);
        HyOrderDetail orderDetails = this.getHyOrderDetail();
        BigDecimal salePrice = orderDetails.getSalePrice();
        BigDecimal costPrice = orderDetails.getCostPrice();
        BigDecimal settleAmount = FlymeUtils.getBigDecimal(orderDetails.getSettleAmount(), "0");
        if (FlymeUtils.isNotEmpty(discountPrice)) {
            salePrice = discountPrice;
        }
        variable.put("票折价", FlymeUtils.getBigDecimal(orderDetails.getDiscountPrice(), "0"));
        variable.put("成本价", costPrice);
        variable.put("销售单价", salePrice);
        variable.put("数量", orderDetails.getSaleNum());
        variable.put("结算价", orderDetails.getSettlePrice());
        variable.put("成本金额", orderDetails.getCostAmount());
        variable.put("应结金额", settleAmount);
        variable.put("销售金额", orderDetails.getSaleAmount());
        variable.put("销售结算标准", FlymeUtils.getBigDecimal(orderDetails.getSettleRate(), "0"));
        return variable;
    }


}
